package org.budo.cmbc.direct.sdk.entity.ryb;

import org.budo.cmbc.direct.sdk.entity.AbstractCmbcDirectResponse;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 如意宝产品最新行情查询
 */
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
public class MELERybProdInfoQueryResponse extends AbstractCmbcDirectResponse {
    private static final long serialVersionUID = 3997304688333995926L;

    /**
     * 每万份收益
     */
    private String profitPerAcc;

    /**
     * 7日年化收益率
     */
    private String annualReturnBy7;

    /**
     * 产品名称
     */
    private String prodSubName;

    /**
     * 产品代码
     */
    private String prodSubId;

    /**
     * 净值日期
     */
    private String navDate;

    /**
     * 是否签约如意宝:0-已签约，1-未签约/已解约
     */
    private String isSignFund;

    public MELERybProdInfoQueryResponse(String channelJnlNo, String responseJson) {
        super(channelJnlNo, responseJson);

        JSONObject jsonObj = JSON.parseObject(responseJson);

        JSONArray jsonArr = jsonObj.getJSONArray("List");

        if (jsonArr != null && jsonArr.size() > 0) {
            JSONObject jsonData = (JSONObject) jsonArr.get(0);

            this.profitPerAcc = jsonData.getString("ProfitPerAcc");
            this.annualReturnBy7 = jsonData.getString("AnnualReturnBy7");
            this.prodSubName = jsonData.getString("ProdSubName");
            this.prodSubId = jsonData.getString("ProdSubId");
            this.navDate = jsonData.getString("NavDate");
        }
    }
}
